package cn.tedu.ivos.dict.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.dict.pojo.dto.DictParam;
import cn.tedu.ivos.dict.pojo.dto.DictQuery;
import cn.tedu.ivos.dict.pojo.vo.DictVO;
import cn.tedu.ivos.dict.service.DictService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/v1/dict")
public class DictController {
    @Autowired
    private DictService dictService;
    @GetMapping("select")
    public JsonResult selectDict(DictQuery dictQuery){
        log.debug("查询字典列表：dictQuery={}",dictQuery);
        List<DictVO> list =  dictService.selectDict(dictQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
    public JsonResult saveDict(DictParam dictParam){
        log.debug("新增字典：dictParam={}",dictParam);
        dictService.saveDict(dictParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult deleteDict(@PathVariable Long id){
        log.debug("删除字典：id={}",id);
        dictService.deleteDict(id);
        return JsonResult.ok();
    }
}
